<?php require 'base/header.php'; ?>
<div class="to_intro_menu">
		<div class="clear"></div>
</div>
<div class="to_grey_wdg_xl branded"> 
    <div class="to_grey_wdg_xl_ins">
        <!-- JCP: Da qui c'è la parte all'interno del div bianco a forma di nuvoletta -->
        <div class="to_sugg_container">
            <div class="to_suggestion_big">
                <div id="to_sugg_container">
                    <div class="to_sugg_content to_event">
						
						<div class="to_insegna">
                            <a class="to_thumb" href="#" title="<?=$info['nome_locale']?>">
								<img src="<?= base_url().'/upload/'.$info['nome_logo'] ?>" width="50" height="50" alt="logo" />
							</a>
                        </div>
						<div class="to_top">
							<h1 style="color: #FF5E99; font-size: 140%">Locale &#171;<?= $info['nome_locale'] ?>&#187;</h1>
							
						</div>
						
						<?php if ($info['nome_gestore']) { ?>
						<div class="to_text xl">
							<h5>di <?= $info['nome_gestore'] ?></h5>
						</div>
						<?php } ?>
						<!-- Info -->
						<?php if ($info['latitude']) { ?>
							<a class="to_link small sfondonero" href="#mappa"><span>Mappa</span></a>
						<?php } ?>
						<?php if (isset($events)) { ?>
							<a class="to_link small sfondonero" href="#eventi"><span>Ultimi eventi</span></a>
						<?php } ?>
						<div class="clear"></div>
						
						<div style="text-align: justify;">
						   <?= auto_link(nl2br($info['descrizione']), 'both', TRUE) ?>  
						</div>
							<?php if ($media->num_rows() > 0) { ?>
							
							<div style="height:110px; margin-top: 30px">
									<h2 style="color: #FF5E99;"><dfn>Foto</dfn></h2>
									<div class="infiniteCarousel carosello_locale" style="text-align: center">
									  <div class="wrapper">
										<ul>
											<?php foreach ($media->result_array() as $m) { ?>
											<?php 
												$nome = explode ('.', $m['nome_file']);
											?>
										  <li><a href="<?= base_url().'/upload/'.$m['nome_file'] ?>"><img src="<?= base_url().'/upload/'.$m['nome_file'] ?>" height="75" width="75" /></a></li>
											<?php } ?>
										</ul>        
									  </div>
									</div>
							</div>
							<?php } ?>
						<hr />
						<fb:like href="<?=current_url()?>" show_faces="true"></fb:like>
					</div>
                </div>
                <div class="to_sugg_ftr"></div>
            </div>
			
        </div>
        <div class="clear"></div>
		<div id="commenti_fb"><fb:comments href="<?=current_url()?>"></fb:comments></div>
	</div>
	<div style="margin-bottom: 10px"><div class="segnaposto_ad" style="width: 620px; height: 90px">Pubblicità 620x90</div></div>
</div>
<div class="clear"></div>

<?php if (isset($events)) { ?>
<div class="to_grey_wdg_xl" style="max-height: 350px; overflow: auto" id="eventi"> 
	<div class="to_grey_wdg_xl_ins">
		<div><h2 style="color: #FF5E99; font-size: 120%">Ultimi eventi inseriti:</h2></div>
		<?php require('util/lista_eventi.php'); ?>
	</div>
</div>
<?php } ?>

<div class="clear"></div>

<?php if ($info['latitude']) { ?>
<div class="to_grey_wdg_xl"> 
    <div class="to_grey_wdg_xl_ins">
		<?php if ($info['latitude']) { ?>
		<?php $carica_api_maps = 'async'; ?>
		<h2 style="color: #FF5E99; font-size: 130%">Dove si trova &laquo;<?=$info['nome_locale']?>&raquo;?</h2>
		<div class="border_map" style="width: 500px; margin-left: 30px"><div id="mappa" class="mappa_gmap"></div></div>
		<?php } ?>
	</div>
</div>
<hr />
<?php } ?>


<?php 
$e = $info;
if ($info['latitude']) { ?>
    <script type="text/javascript">// <![CDATA[
	function api_maps_caricata() {
		// NB: questa funzione è più o meno ripetuta per locali, eventi, home e importazione... separare?
		var latlng = new google.maps.LatLng(<?= $e['latitude'] ?>, <?= $e['longitude'] ?>);
		var myOptions = {
			zoom: 14,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.HYBRID,
			streetViewControl: true
		}
		var image = '<?=base_url() ?>/images/food_icons/';
		<?php 
			switch(trim($e['categoria'])) {
				case "pub":
					echo "image += 'beer_heineken-32x32.png';";
				break;
				case "disco":
					echo "image += 'Music-32.png';";
				break;
				case "concerti":
					echo "image += 'Stratocaster-guitar-blue-32.png';";
				break;
				case "cinema":
					echo "image += 'Cinema-Popcorn-32.png';";
				break;
				case "cultura":
					echo "image += 'Secret-book-32.png';";
				break;
				default:
					echo "image = '".base_url()."/favicon.ico';";
				break;
			}
		?>
	
		var contentString = '<h3><?= $e['nome_locale'] ?></h3>';
		var map = new google.maps.Map(document.getElementById("mappa"), myOptions);
		var infowindow = new google.maps.InfoWindow({
			content: contentString
		});
		var marker = new google.maps.Marker({
			map: map,
			position: latlng,
			title: "<?= $e['nome_locale'] ?>",
			icon: image
		});
		google.maps.event.addListener(marker, 'click', function() {
		  infowindow.open(map,marker);
		});
		google.maps.event.addListener(marker, 'click', function() {
		   if (marker.getAnimation() != null) {
			  marker.setAnimation(null);
			} else {
			  marker.setAnimation(google.maps.Animation.BOUNCE);
			}
		});
	}
    // ]]></script>
<?php } ?>

<?php require 'base/footer.php'; ?>
